home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1996
/
MacHack 1996.toast
/
Hacks
/
Hacks ’90
/
MiniFinder
/
mini.a
< prev
next >
Wrap
Text File
|
1990-06-13
|
6KB
|
273 lines
* MiniFinder -- Small Icons on the Desktop.
* by Dean Yu
INCLUDE 'ToolEqu.a'
INCLUDE 'SysEqu.a'
INCLUDE 'Traps.a'
INCLUDE 'QuickEqu.a'
main PROC EXPORT
IMPORT copyPatch
IMPORT rectPatch
IMPORT rgnPatch
IMPORT cPort
move.l d7,-(sp)
lea main,a0
_RecoverHandle ,SYS
move.l a0,-(sp)
_DetachResource ; Detach it so it sticks around
move.w #$ec,d0 ; Trap number for _CopyBits
_GetTrapAddress ,NEWTOOL
lea copyPatch,a1
move.l a0,2(a1) ; Save old _CopyBits routine
move.l a1,a0
move.w #$ec,d0
_SetTrapAddress ,NEWTOOL
move.w #$a4,d0 ; Trap number for _InverRect
_GetTrapAddress ,NEWTOOL
lea rectPatch,a1
move.l a0,2(a1) ; Save old _InverRect routine
move.l a1,a0
move.w #$a4,d0
_SetTrapAddress ,NEWTOOL
move.w #$db,d0 ; Trap number for _CloseRgn
_GetTrapAddress ,NEWTOOL
lea rgnPatch,a1
move.l a0,2(a1) ; Save old _CloseRgn routine
move.l a1,a0
move.w #$db,d0
_SetTrapAddress ,NEWTOOL
move.w #$9f,d0
_GetTrapAddress ,NEWTOOL ; Unimplemented trap number
move.l a0,d7
move.w #$aa00,d0 ; Trap number for _OpenCPort
_GetTrapAddress ,NEWTOOL
cmp.l a0,d7
beq.s noCQD ; No Color QuickDraw
lea cPort,a1
move.l a0,2(a1) ; Save old _OpenCPort routine
move.l a1,a0
move.w #$aa00,d0
_SetTrapAddress ,NEWTOOL
bra.s ExitINIT
noCQD move.w #$6f,d0 ; Trap number for _OpenPort
_GetTrapAddress ,NEWTOOL
lea cPort,a1
move.l a0,2(a1) ; Save old _OpenPort routine
move.l a1,a0
move.w #$6f,d0
_SetTrapAddress ,NEWTOOL
ExitINIT move.l (sp)+,d7
rts
ENDPROC
copyPatch PROC EXPORT
IMPORT rgnPatch
IMPORT rectPatch
copyVars RECORD {A6Link},DECR
paramBegin equ *
srcBits ds.l 1 ; Pointer to source bit map
dstBits ds.l 1 ; Pointer to destination bit map
srcRect ds.l 1 ; Pointer to source rectangle
dstRect ds.l 1 ; Pointer to destination rectangle
mode ds.w 1 ; Transfer mode
maskRgn ds.l 1 ; Region handle
paramSize equ paramBegin - *
retAddr ds.l 1 ; Return address
A6Link ds.l 1 ; Stack frame
localSize equ *
ENDR
WITH copyVars
bra.s startCopy
oldCopy ds.l 1
theDesktop ds.l 1
startCopy lea FinderName,a0 ; Make sure we’re only active in the Finder
lea CurApName,a1
cmpi.b #$ff,(a0) ; Special case for startup time
beq.s toOldCopy
cmp.l (a0)+,(a1)+
bne.s toOldCopy
cmp.w (a0)+,(a1)+
bne.s toOldCopy
move.l theDesktop,a0 ; Don’t do anything unless we’re drawing in the
move.l (a5),a1 ; desktop port
move.l (a1),a1
cmp.l a0,a1
bne.s toOldCopy
link a6,#localSize
move.l srcRect(a6),a0
move.l (a0),d0
move.l botRight(a0),d1
sub.l d0,d1
cmpi.l #$00200020,d1 ; Make sure source rectangle is 32 x 32
bne.s exitCopy
move.l dstRect(a6),a0 ; Get pointer to desination rectangle
move.l (a0),d0 ; Get topLeft
move.l botRight(a0),d1 ; Get botRight
sub.l d0,d1 ; Get size of destination rectangle
cmpi.l #$00200020,d1 ; Is it 32 x 32?
bne.s exitCopy ; If not, don’t do anything
addi.l #$00100010,d0 ; Make 16 x 16 destRect
move.l d0,botRight(a0)
move.l a0,-(sp) ; Center it in old destRect
move.l #$000f0008,-(sp)
_OffsetRect
cmpi.w #srcBic,mode(a6)
bne.s exitCopy
lea rgnPatch,a0
move.w #$ff,6(a0)
lea rectPatch,a0
move.w #$ff,6(a0)
exitCopy unlk a6
toOldCopy move.l oldCopy,a0
jmp (a0)
ENDPROC
rectPatch PROC EXPORT
IMPORT rgnPatch
bra.s startPatch
oldRect ds.l 1
active dc.w 0
startPatch move.w active,d0
beq.s toOldRect
lea FinderName,a0 ; Make sure we’re only active in the Finder
lea CurApName,a1
cmp.l (a0)+,(a1)+
bne.s toOldRect
cmp.w (a0)+,(a1)+
bne.s toOldRect
lea rgnPatch,a1
move.l 4(sp),a0
move.l (a0)+,8(a1)
move.l (a0)+,12(a1)
lea active,a0
clr.w (a0)
toOldRect move.l oldRect,a0
jmp (a0)
ENDPROC
rgnPatch PROC EXPORT
bra.s startPatch
oldRgn ds.l 1
active dc.w 0
theRect ds.l 1
theRect2 ds.l 1
whichWind ds.l 1
startPatch move.w active,d0
beq.s toOldCloseRgn
lea FinderName,a0 ; Make sure we’re only active in the Finder
lea CurApName,a1
cmp.l (a0)+,(a1)+
bne.s toOldCloseRgn
cmp.w (a0)+,(a1)+
bne.s toOldCloseRgn
sub.w #2,sp
pea whichWind
move.l (sp),-(sp)
_GetMouse
_LocalToGlobal
move.l whichWind,-(sp)
pea whichWind
_FindWindow
tst.w (sp)+
bne.s toOldCloseRgn
move.l 4(sp),-(sp)
move.l oldRgn,a0
jsr (a0)
move.l 4(sp),-(sp)
move.l #$00060006,-(sp)
_InsetRgn
move.l #10,d0
_NewHandle
lea whichWind,a1
move.l a0,(a1)
move.l (a0),a0
move.w #10,(a0)+
move.l theRect,(a0)+
move.l theRect2,(a0)+
move.l 4(sp),a0
move.l a0,-(sp)
move.l whichWind,-(sp)
move.l a0,-(sp)
_UnionRgn
move.l whichWind,a0
_DisposHandle
lea active,a0
clr.w (a0)
move.l (sp)+,a0
add.w #4,sp
jmp (a0)
toOldCloseRgn move.l oldrgn,a0
jmp (a0)
ENDPROC
cPort PROC EXPORT
IMPORT copyPatch
bra.s startCPort
oldCPort ds.l 1
active dc.w 1
startCPort move.w active,d0
beq.s toOldCPort
lea FinderName,a0 ; Make sure we’re only active in the Finder
lea CurApName,a1
cmpi.b #$ff,(a0) ; Special case for startup time
beq.s toOldCPort
cmp.l (a0)+,(a1)+
bne.s toOldCPort
cmp.w (a0)+,(a1)+
bne.s toOldCPort
lea active,a0
clr.w (a0)
lea copyPatch,a0
move.l 4(sp),6(a0) ; Save desktop port
toOldCPort move.l oldCPort,a0
jmp (a0)
ENDPROC
END